package com.hanlin;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.junit.Test;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * 描述：rabbitMQ测试  生产者
 * @author:hl.yuan
 * @date:2021-03-13
 */
public class RabbitMqTest {

    /**
     * 消息发送
     */
    @Test
    public void send() throws IOException, TimeoutException {
        //创建连接工厂
        Connection connection = RabbitUtils.getConnection();
        //创建通道
        Channel channel = connection.createChannel();
        //参数1: 是否持久化  参数2:是否独占队列 参数3:是否自动删除  参数4:其他属性
        channel.queueDeclare("hello",true,false,false,null);
        channel.basicPublish("","hello", null,"hello rabbitmq 123456".getBytes());
        channel.close();
        connection.close();

    }

}
